package cn.rslee.java.demos.test

import org.apache.spark.SparkConf
import org.apache.spark.SparkContext

object MapAndFlatmap {
  def main(args: Array[String]): Unit = {
    val sc = new SparkContext(new SparkConf().setAppName("map_flatMap_demo").setMaster("local"));
    val arrayRDD =sc.parallelize(Array("a_b","c_d","e_f"));
    arrayRDD.foreach(println); //打印结果1
    arrayRDD.map(string=>{
      string.split("_")
    }).foreach(x=>{
      println(x.mkString(",")) //打印结果2
    })

    arrayRDD.flatMap(string=>{
      string.split("_")
    }).foreach(x=>{
      println(x.mkString(","))//打印结果3
    })
    
   
  }
}